//
//  MyButtonTableViewCell.m
//  NewMusic
//
//  Created by dllo on 15/11/12.
//  Copyright © 2015年 Going. All rights reserved.
//

#import "MyButtonTableViewCell.h"

@implementation MyButtonTableViewCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self)
    {
        [self creatSubView];
    }
    return self;
}
- (void)creatSubView
{
    UIView *view = [[UIView alloc] initWithFrame:CGRectMake(0, 10, 375, 280)];
    view.backgroundColor = [UIColor whiteColor];
    view.alpha = 0.05;
    view.userInteractionEnabled = YES;
    [self.contentView addSubview:view];
    [view release];
    
    NSArray *arr = [NSArray arrayWithObjects:@"全部歌曲", @"下载歌曲", @"最近播放", @"我最喜欢", @"下载MV", @"听歌识曲", nil];
    
    for (int i = 0; i < 6; i++)
    {
        UIView *viewButton = [[UIView alloc] init];
        if (i < 3)
        {
            viewButton.frame = CGRectMake(10 + 115 * i, 30, 105, 105);
            //个数创建
            UILabel *labelNum = [[UILabel alloc] initWithFrame:CGRectMake(7.5, 85, 90, 15)];
            labelNum.text = @"12";
            labelNum.textAlignment = NSTextAlignmentCenter;
            labelNum.textColor = [UIColor colorWithRed:150 / 255.0 green:150 / 255.0 blue:150 / 255.0 alpha:1.0];
            labelNum.font = [UIFont systemFontOfSize:18.0];
            [viewButton addSubview:labelNum];
            [labelNum release];
            
        } else {
            viewButton.frame = CGRectMake(10 + 115 * (i - 3), 165, 105, 105);
        }
        //图片创建
        UIImageView *imageView = [[UIImageView alloc] initWithFrame:CGRectMake(32.5, 10, 40, 40)];
        imageView.image = [UIImage imageNamed:[NSString stringWithFormat:@"icon-homePage%d", (i + 1)]];
        [viewButton addSubview:imageView];
        [self.contentView addSubview:viewButton];
        [viewButton release];
        
        //标题创建
        UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(7.5, 60, 90, 20)];
        label.text = arr[i];
        label.textAlignment = NSTextAlignmentCenter;
        label.textColor = [UIColor whiteColor];
        [viewButton addSubview:label];
        [label release];
        
        // 手势创建
        UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(tapAction:)];
        [viewButton addGestureRecognizer:tap];
        UIView *tapView = [tap view];
        tapView.tag = 1310 + i;
        [tap release];
    }
    
}
- (void)tapAction:(UITapGestureRecognizer *)sender
{
    [self.delegate changeViewInButtonCell:[sender view].tag - 1310];
}

- (void)awakeFromNib {
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
